package com.iedu.demo.lgq.service.impl;

import com.iedu.demo.lgq.entity.TbCategory;
import com.iedu.demo.lgq.util.DateUtil;
import com.iedu.demo.lgq.util.PageUtil;
import com.iedu.demo.lgq.mapper.CategoryMapper;
import com.iedu.demo.lgq.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    private final CategoryMapper categoryMapper;

    public CategoryServiceImpl(CategoryMapper categoryMapper) {
        this.categoryMapper = categoryMapper;
    }

    @Override
    public List<TbCategory> getAllCategories() {
        return categoryMapper.getAllCategories();
    }

    @Override
    public List<TbCategory> getSubCategoriesByParentId(Long parentId) {
        return categoryMapper.getSubCategoriesByParentId(parentId);
    }

    @Override
    public TbCategory getCategoryById(Long categoryId) {
        return categoryMapper.getCategoryById(categoryId);
    }

    @Override
    public int insertCategory(TbCategory category) {
        return categoryMapper.insertCategory(category);
    }

    @Override
    public int updateCategory(TbCategory category) {
        return categoryMapper.updateCategory(category);
    }

    @Override
    public int deleteCategory(Long categoryId) {
        return categoryMapper.deleteCategory(categoryId);
    }
}